/*
 * @Description:
 * @Version: 2.0
 * @Autor: xudongxu
 * @Date: 2019-12-05 14:18:22
 * @LastEditors: xudongxu
 * @LastEditTime: 2019-12-09 19:50:02
 */
#include <future>
#include <iostream>
#include <regex>
using namespace std;

std::string get_ip( const std::string& url ) {
    std::string ip;
    std::regex ip_reg( ".*@(((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)):.*" );
    std::smatch matchResult;
    //正则匹配
    if ( std::regex_match( url, matchResult, ip_reg ) ) {
        for ( size_t i = 1; i < matchResult.size(); ++i ) {
            ip = matchResult[1];
        }
        return ip;
    } else {
        return "";
    }
}

int main( int argc, char* argv[] ) {
    std::string url = "rtsp://admin:ad53937301@192.168.1.64:554/h264/ch1/main/av_stream";
    std::cout << "ip=" << get_ip( url ) << std::endl;
    std::getchar();
    return 0;
}